import { createRouter, createWebHistory } from 'vue-router'

const routes = [
   {
    path: "/",
    redirect: "/login",
  },
  {
    path: "/login",
    name: "Login",
    component: () => import("@/pages/login.vue"),
    meta: { title: "用户登录" },
  },
  {
    path: "/register",
    name: "Register",
    component: () => import("@/pages/Register.vue"),
    meta: { title: "用户注册" },
  },
  {
    path: "/notifications",
    name: "Notifications",
    component: () => import("@/pages/Notifications.vue"),
    meta: { title: "消息通知" },
  },
  // ==================== 监测报警模块 ====================
  {
    path: '/monitoring-indicators',
    name: 'MonitoringIndicators',
    component: () => import('@/pages/MonitoringIndicators.vue'),
    meta: { title: '监测指标统计' }
  },
  {
    path: '/data-aggregation',
    name: 'DataAggregation',
    component: () => import('@/pages/DataAggregation.vue'),
    meta: { title: '数据汇聚' }
  },
  {
    path: '/regional-display',
    name: 'RegionalDisplay',
    component: () => import('@/pages/RegionalDisplay.vue'),
    meta: { title: '区域化展示' }
  },
  {
    path: '/alarm-event-management',
    name: 'AlarmEventManagement',
    component: () => import('@/pages/AlarmEventManage.vue'),
    meta: { title: '报警事件管理' }
  },
  // ==================== 风险研判模块 ====================
  {
    path: '/risk-analysis',
    name: 'RiskAnalysis',
    component: () => import('@/pages/RiskAnalysis.vue'),
    meta: { title: '风险管理与分析' }
  },
  {
    path: '/focus',
    name: 'RiskFocus',
    component: () => import('@/pages/RiskFocus.vue'),
    meta: { title: '全部重点风险提示' }
  },
  {
    path: '/risk-warning-push',
    name: 'RiskWarningPush',
    component: () => import('@/pages/RiskWarningPush.vue'),
    meta: { title: '预警信息推送' }
  },
  {
    path: '/intelligent-risk-assessment',
    name: 'IntelligentRiskAssessment',
    component: () => import('@/pages/IntelligentRiskAssessment.vue'),
    meta: { title: '智能风险评估' }
  },


  // ==================== 在线巡查模块 ====================
  {
    path: '/summary-information',
    name: 'SummaryInformation',
    component: () => import('@/pages/SummaryInformation.vue'),
    meta: { title: '企业信息汇总' }
  },
  {
    path: '/patrol',
    name: 'Patrol',
    component: () => import('@/pages/Patrol.vue'),
    meta: { title: '巡查功能' }
  },
  {
    path: '/search',
    name: 'Search',
    component: () => import('@/pages/Search.vue'),
    meta: { title: '检索功能' }
  },
  {
    path: '/screen-display',
    name: 'ScreenDisplay',
    component: () => import('@/pages/ScreenDisplay.vue'),
    meta: { title: '一屏汇聚展示' }
  },
  {
    path: '/task-details',
    name: 'TaskDetails',
    component: () => import('@/pages/TaskDetails.vue'),
    meta: { title: '任务详情' }
  },
  {
    path: '/information-list',
    name: 'InformationList',
    component: () => import('@/pages/InformationList.vue'),
    meta: { title: '预警信息列表' }
  },
  // ==================== 综合分析模块 ====================
  {
    path: '/equipment',
    name: 'Equipment',
    component: () => import('@/pages/Equipment.vue'),
    meta: { title: '联网与设备分析' }
  },

  {
    path: '/application',
    name: 'Application',
    component: () => import('@/pages/Application.vue'),
    meta: { title: '应用情况分析' }
  },
  {
    path: '/data-quality',
    name: 'DataQuality',
    component: () => import('@/pages/DataQuality.vue'),
    meta: { title: '数据质量分析' }
  },
  {
    path: '/report',
    name: 'Report',
    component: () => import('@/pages/Report.vue'),
    meta: { title: '定期专题报告' }

  },
   {
    path: "/all-equipment",
    name: "AllEquipment",
    component: () =>import("@/pages/AllEquipment.vue"),
    meta: { title: "全部设备" },
  },
  // ==================== 系统管理模块 ====================
  {
    path: '/user-permission',
    name: 'UserPermission',
    component: () => import('@/pages/UserPermission.vue'),
    meta: { title: '用户权限管理' }
  },
  {
    path: '/system-manage',
    name: 'SystemManage',
    component: () => import('@/pages/SystemManage.vue'),
    meta: { title: '系统配置管理' }
  },
  {
    path: '/data-manage',
    name: 'DataManage',
    component: () => import('@/pages/DataManage.vue'),
    meta: { title: '数据管理' }
  },
  {
    path: '/monitoring',
    name: 'Monitoring',
    component: () => import('@/pages/Monitoring.vue'),
    meta: { title: '系统监控与维护' }
  },
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

// 路由守卫 - 设置页面标题
router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = `${to.meta.title} - 钢铁企业安全生产智能监管平台`
  }
  next()
})

export default router